<?php
$GLOBALS['Md'] = 'XFK0WK2A';
$_SESSION[$SESAMD] = $GLOBALS['Md'];
$__areatitle[1] = 'Remessas a Tratamento';
$__areatitle[2] = 'Remessas a Pagamento';
$_coltype[0] = '';
$_coltype[1] = 'URG';

$GET = $GLOBALS['MYT']->db_array("SELECT FraID,FraFechaIngreso,
  IF(FraModo=2,FraIncReferenciaCo,CONCAT(FraOrigen0,'-',LPAD(FraReferenciaAg,6,0))) AS Referencia,
  IF(FraModo=2,IncCorr.CorrAlias,OutCorr.CorrAlias) AS Correspondente,FraMonCobro,FraMonDPago,
  FraUrgente,FraARecibir,FraEnviado,FraCargo,FraTasa,FraCliNombre,FraBnfNombre,sg_Abreviatura AS FraStatus, IF(FraModo=1,'Enviar','Pagar') AS FraModo
   FROM facturas IGNORE INDEX (IdxCli)
   INNER JOIN facturasextjoins ON FraID = FraExtID
   LEFT JOIN facturas_income ON FraID = FraIncID
   INNER JOIN hd_statusfacturas ON sg_ID = FraStatus
   LEFT JOIN corresponsales AS IncCorr ON IncCorr.CorrNumero = FraIncCorresponsal
   LEFT JOIN corresponsales AS OutCorr ON OutCorr.CorrNumero = FraCorresponsal
   WHERE FraOrigen0 = {$_SESSION[$SESSCD]} AND
		((FraModo = 1 AND FraFechaAlb IS NULL AND FraFecha IS NULL AND FraStatus NOT IN (1,9,10,21))
		OR (FraModo = 2 AND FraAlbaran > 0 AND FraNumero = 0 AND FraStatus IN (11,16)))
		AND FraModo = " . $_GET['NCM']);
$CGET = $GET[0];
$prStr = '';
?>
<div class="title"><?php echo $__areatitle[$_GET['NCM']].rt_field('hselect', 'ED', 'ListStatus', 0, 'Todas#0', '', '', ''); ?></div>
<table width="100%"  border="0" cellpadding="2" cellspacing="1">
    <tr style="background-color:#E5E5E5;height:18px;text-align:center">
        <td NOWRAP style="width:50px">Operacao</td>
        <td NOWRAP style="width:50px">Canal</td>
        <td NOWRAP style="width:80px">Corresp.</td>
        <td NOWRAP style="width:80px">Remessa </td>
        <td NOWRAP style="width:200px">Remetente</td>
        <td NOWRAP style="width:200px">Beneficiario</td>
        <td NOWRAP style="width:50px">C&acirc;mbio</td>
        <td NOWRAP style="width:50px">Taxa</td>
        <td NOWRAP style="width:50px">Enviado</td>
        <td NOWRAP style="width:50px">A Pagar</td>
        <td NOWRAP style="width:120px">Data</td>
        <td NOWRAP style="width:50px">Urgente</td>
        <td NOWRAP style="width:50px">Estado</td>
    </tr>
    <?php
    for ($g = 1; $g <= $CGET; $g++) {
        $prStr .= '<tr bgcolor="' . gridlines($g) . '" style="height:20px">
        <td NOWRAP>'.rt_field('button', 'ED', 'FraID', $GET[$g]['FraID'], '', '', '', '" onclick="modalwindow(\'Propriedades da Remessa\',\'_response/call.php?get=Operative/frm_transferdetails&RSID=' . $GET[$g]['FraID'] . '\',680,500);').'</td>
        <td NOWRAP>' . $GET[$g]['FraModo'] . '</td>
        <td NOWRAP><b>' . $GET[$g]['Correspondente'] . '</b></td>
        <td NOWRAP><b>' . $GET[$g]['Referencia'] . '</b></td>
        <td NOWRAP>' . $GET[$g]['FraCliNombre'] . '</td>
        <td NOWRAP>' . $GET[$g]['FraBnfNombre'] . '</td>
        <td NOWRAP>' . number_format($GET[$g]['FraTasa'], 4) . '</td>
        <td NOWRAP>' . number_format($GET[$g]['FraCargo'], 2) . '</td>
        <td NOWRAP align="right">' . number_format($GET[$g]['FraEnviado'], 2) . $_SESSION[$SESSST . 'CURS'][$GET[$g]['FraMonCobro']]['CurLabel'] . '</td>
        <td NOWRAP align="right">' . number_format($GET[$g]['FraARecibir'], 2) . $_SESSION[$SESSST . 'CURS'][$GET[$g]['FraMonDPago']]['CurLabel'] . '</td>
        <td NOWRAP align="center">' . $GET[$g]['FraFechaIngreso'] . '</td>
        <td NOWRAP align="center">' . $_coltype[$GET[$g]['FraUrgente']] . '</td>
        <td NOWRAP>' . $GET[$g]['FraStatus'] . '</td>
      </tr>';
    }
    $prStr .= '</table>';
    echo $prStr;